import os
import argparse


def main(origin_path, pics_path):
    real_path = os.getcwd()
    template_path = os.path.join(real_path, "template")
    files = [os.path.join(template_path, file) for file in os.listdir(template_path)]
    for file in files:
        with open(file, 'r', encoding="utf-8") as f:
            template = f.read()
        if origin_path in template:
            print(file)
            template = template.replace(origin_path, pics_path)
            with open(file, 'w', encoding="utf-8") as f:
                f.write(template)


if __name__ == '__main__':
    parser = argparse.ArgumentParser("指定图片文件夹")
    parser.add_argument('--origin_path', default="${图片文件夹}", help="修改前图片文件夹路径")
    parser.add_argument('--pics_path', required=True, help="修改后图片文件夹路径")
    args = parser.parse_args()
    main(args.origin_path, args.pics_path)
